package com.gzhuxj201.mapper;

import com.gzhuxj201.entity.Teacher;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TeacherMapper {

    //mysql层要特别注意gender不能用int 一定要用Integer,Integer的默认值是null，int的默认值是0 如果用int接收且gender不传值会报gender空指针异常
    //因为int gender=null是错误的,int不能接收null 而包装类型Integer gender=null可以
    List<Teacher> page(String tno, String username, Short gender);

    @Insert("insert into teacher(tno,username,email,gender) values(#{tno},#{username},#{email},#{gender})")
    void add(Teacher teacher);

    @Select("select * from teacher where tno=#{tno}")
    Teacher selectById(Integer tno);


    void update(Teacher teacher);

    int deleteByTnos(List<Integer> tnos);

    @Select("select * from teacher where username=#{username} and password=#{password}")
    Teacher selectByUsernameAndPassword(String username, String password);

    @Select("select * from teacher where username=#{username}")
    Teacher selectByUsername(String username);
}
